package com.jeff.work;

public class PCB {
    String name;
    int priority;
    int burstTime;
    int submitTime;
    int startTime;
    int finishTime;
    int usedTime;
    int jobLength;
    String status;

    public PCB() {
    }

    public PCB(String name, int priority, int burstTime, int submitTime, int usedTime, int jobLength) {
        this.name = name;
        this.priority = priority;
        this.burstTime = burstTime;
        this.submitTime = submitTime;
        this.usedTime = usedTime;
        this.jobLength = jobLength;
        this.status = "wait";
    }

    // 计算等待时间
    public int getWaitingTime() {
        return startTime - submitTime;
    }

    // 计算服务时间
    public int getServiceTime() {
        return finishTime - startTime;
    }

    /**
     * 计算每个进程的响应比。
     * 通过计算响应比，可以为不同的进程分配不同的优先级，以优化系统的调度性能。
     *
     */
    public double getResponseRatio() {
        return (double) (getWaitingTime() + getServiceTime()) / getServiceTime();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    public int getBurstTime() {
        return burstTime;
    }

    public void setBurstTime(int burstTime) {
        this.burstTime = burstTime;
    }

    public int getSubmitTime() {
        return submitTime;
    }

    public void setSubmitTime(int submitTime) {
        this.submitTime = submitTime;
    }

    public int getStartTime() {
        return startTime;
    }

    public void setStartTime(int startTime) {
        this.startTime = startTime;
    }

    public int getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(int finishTime) {
        this.finishTime = finishTime;
    }

    public int getUsedTime() {
        return usedTime;
    }

    public void setUsedTime(int usedTime) {
        this.usedTime = usedTime;
    }

    public int getJobLength() {
        return jobLength;
    }

    public void setJobLength(int jobLength) {
        this.jobLength = jobLength;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
}